package ace.tool.generate.code.impl.resolver.scheme.resolver.api;

import ace.tool.generate.code.impl.resolver.scheme.model.bo.api.ConstantClassInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.ClassFileInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.CommonInfo;
import ace.tool.generate.code.impl.resolver.scheme.model.dto.ProjectInfo;
import ace.tool.generate.code.impl.resolver.scheme.resolver.ClassFileInfoResolver;
import ace.tool.generate.code.impl.service.model.input.GenerateInput;
import lombok.Builder;
import lombok.RequiredArgsConstructor;

/**
 * @author caspar
 * @date 2023/11/17 10:34
 */
@Builder
@RequiredArgsConstructor
public class ConstantClassInfoResolver {
  private final GenerateInput input;
  private final CommonInfo commonInfo;
  private final ProjectInfo apiProjectInfo;

  public ConstantClassInfo resolve() {
    ClassFileInfo constantClassInfo =
        ClassFileInfoResolver.builder()
            .className(commonInfo.getProjectClassName())
            .classNameSuffix(input.getConstantClassNameSuffix())
            .classPackagePrefix(input.getConstantClassPackagePrefix())
            .rootPackageFullName(commonInfo.getRootPackageFullName())
            .sourceCodeRootDir(apiProjectInfo.getSourceCodeRootDir())
            .build()
            .resolve();

    return ConstantClassInfo.builder().info(constantClassInfo).build();
  }
}
